<?php

namespace app\api\controller\User;

use app\services\UserSignService;
use support\Request;

class SignController
{
    public function signDates(Request $request)
    {
        try {
            $data = UserSignService::getSignDates(get_user_id());

            return ok_rsp('成功', $data);
        } catch (\Exception $e) {
            return err_rsp($e->getMessage());
        }
    }

    public function info(Request $request)
    {
        try {
            $data = UserSignService::signInfo(get_user_id());

            return ok_rsp('成功', $data);
        } catch (\Exception $e) {
            return err_rsp($e->getMessage());
        }
    }

    public function list(Request $request)
    {
        try {
            $page = $request->post('page', 1);
            $length = $request->post('length', 10);
            $data = UserSignService::getList(get_user_id(), $page, $length);

            return ok_rsp('成功', $data);
        } catch (\Exception $e) {
            return err_rsp($e->getMessage());
        }
    }

    public function sign(Request $request)
    {
        try {
            UserSignService::sign(get_user_id());

            return ok_rsp('成功');
        } catch (\Exception $e) {
            return err_rsp($e->getMessage());
        }
    }
}